﻿/****** Object:  Table [dbo].[Bug]    Script Date: 08/18/2011 18:58:05 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Bug](
	[BugId] [int] IDENTITY(1,1) NOT NULL,
	[ProjectComponentId] [int] NOT NULL,
	[OwnerId] [int] NOT NULL,
	[Title] [nvarchar](64) NOT NULL,
	[Type] [int] NOT NULL,
	[Priority] [int] NOT NULL,
	[Stamp] [datetime] NOT NULL,
	[Status] [int] NOT NULL,
 CONSTRAINT [PK_Bug] PRIMARY KEY CLUSTERED 
(
	[BugId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[Bug]  WITH CHECK ADD  CONSTRAINT [FK_Bug_ProjectComponent] FOREIGN KEY([ProjectComponentId])
REFERENCES [dbo].[ProjectComponent] ([ProjectComponentId])
ON DELETE CASCADE
GO

ALTER TABLE [dbo].[Bug] CHECK CONSTRAINT [FK_Bug_ProjectComponent]
GO

ALTER TABLE [dbo].[Bug]  WITH CHECK ADD  CONSTRAINT [FK_Bug_User] FOREIGN KEY([OwnerId])
REFERENCES [dbo].[User] ([UserId])
GO

ALTER TABLE [dbo].[Bug] CHECK CONSTRAINT [FK_Bug_User]
GO

ALTER TABLE [dbo].[Bug] ADD  CONSTRAINT [DF_Bug_Stamp]  DEFAULT (getdate()) FOR [Stamp]
GO


